<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hzb.erp.api.pc.creditMall.mapper.CreditExchangeMapper">
    <select id="getList" resultType="com.hzb.erp.api.pc.creditMall.pojo.CreditExchangeVO">
        select t1.*, t4.name credit_mall_name, t4.cover,
        t2.name as student_name, t3.mobile, t5.name verify_staff_name, t6.name school_name
        from credit_exchange t1
        left join student t2 on t2.id = t1.student_id
        left join user t3 on t3.id = t1.user_id
        left join credit_mall t4 on t4.id = t1.credit_mall_id
        left join staff t5 on t5.id = t1.verify_staff
        left join org t6 on t6.id = t1.school_id
        <where>
            t1.deleted = 0
            <if test="param.studentId != null">
                AND t1.student_id = #{param.studentId}
            </if>
            <if test="param.giftName != null and param.giftName != ''">
                AND t4.name like concat('%', #{param.giftName}, '%')
            </if>
            <if test="param.creditMallId != null">
                AND t4.credit_mall_id = #{param.credit_mall_id}
            </if>
            <if test="param.verifyState != null">
                AND t1.verify_state = #{param.verifyState}
            </if>
            <if test="param.startDate != null and param.endDate != null">
                AND ( date(t1.add_time) &gt;= #{param.startDate} and  date(t1.add_time) &lt;= #{param.endDate} )
            </if>
        </where>
        order by t1.id desc
    </select>
</mapper>
